/*
 * @copyright: Huang Ding
 * @Author: ding-cx
 * @Date: 2022-05-31 10:27:00
 * @LastEditors: ding
 * @LastEditTime: 2022-07-21 16:43:01
 * @Description: 控制记录、陌生人记录等查询、管理
 */

import { actions } from "../../http/actions";
import { hc } from "../../hc";
import HcWanBaseCmdService from "./HcWanBaseCmdService";

export default class HcWanCmdRecordService extends HcWanBaseCmdService {
	/**
	 * 获取控制记录总条数（按时间范围）
	 *
	 * @param {string} begin 开始时间 形如 yyyy-MM-ddThh:mm:ss
	 * @param {string} end 结束时间 形如 yyyy-MM-ddThh:mm:ss
	 * @return {*}
	 * @memberof BaseHaiQingInterfaceRecordService
	 */
	async getSearchControlNum(begin: string, end: string) {
		const operator = actions.SearchControlNum;
		const info: hc.http.IRequestSearchControlNumInfo = {
			DeviceID: this.device.deviceId,
			BeginTime: begin,
			EndTime: end,
		};
		const res = await this.execCMD(operator, { info }, true);
		return res;
	}

	/**
	 * 获取控制记录人员信息 条件自行传入
	 *  - 参考文档 3.22.2
	 *
	 * @template Response
	 * @param {*} searchParams
	 * @return {*}
	 * @memberof BaseHaiQingInterfaceRecordService
	 * this.service.baseHaiQing.interface.record.getSearchControlPersonInfo(machine, searchParams);
	 */
	async getSearchControlPersonInfo(searchParams: any) {
		const operator = actions.SearchControl;
		const info = searchParams;
		const res = await this.execCMD<any>(operator, { info }, true);
		return res;
	}

	/**
	 * 获取抓拍记录总条数（按时间范围）
	 *
	 * @param {string} begin 开始时间 形如 yyyy-MM-ddThh:mm:ss
	 * @param {string} end 结束时间 形如 yyyy-MM-ddThh:mm:ss
	 * @return {*}
	 * @memberof BaseHaiQingInterfaceRecordService
	 */
	async getSearchCaptureNum(begin: string, end: string) {
		const operator = actions.SearchCaptureNum;
		const info: hc.http.IRequestSearchCaptureNumInfo = {
			DeviceID: this.device.deviceId,
			BeginTime: begin,
			EndTime: end,
		};
		const res = await this.execCMD<hc.http.IResponseSearchCaptureNum>(
			operator,
			{ info },
			true
		);
		return res;
	}

	/**
	 * 获取抓拍记录人员信息 条件自行传入
	 *  - 参考文档 3.26.2
	 *
	 * @param {*} searchParams
	 * @return {*}
	 * @memberof BaseHCWANCMDRecordService
	 */
	async getSearchCapturePersonInfo<T extends {}>(searchParams: any) {
		const operator = actions.SearchCapture;
		const info = searchParams;
		const res = await this.execCMD<T>(operator, { info }, true);
		return res;
	}

	/**
	 *
	 * 手动推送时间范围内的控制记录
	 *
	 * @param {string} start 开始时间 形如 yyyy-MM-ddThh:mm:ss
	 * @param {string} end 结束时间 形如 yyyy-MM-ddThh:mm:ss
	 * @return {*}
	 * @memberof BaseHCWANCMDRecordService
	 */
	async manualPushControlRecord(start: string, end: string) {
		const operator = actions.ManualPushRecords;
		const info: hc.http.IRequestManualPushRecordsInfo = {
			DeviceID: this.device.deviceId,
			TimeS: start,
			TimeE: end,
		};
		const res = await this.execCMD<hc.http.IResponseManualPushRecords>(
			operator,
			{ info },
			true
		);
		return res;
	}
}
